import { request } from "@/utils/request";
import type {
  DeleteParams,
  ExercisesParams,
  QueryParams,
  QueryResult,
} from "./typing";
import type { PageResult, ResponseBody } from "@/api/typing";

/**新增习题 */
export const add = (params: ExercisesParams) => {
  return request.post<ExercisesParams, ResponseBody>(
    "/answer/exercises/add",
    params
  );
};

/**修改习题 */
export const update = (params: ExercisesParams) => {
  return request.put<ExercisesParams, ResponseBody>(
    "/answer/exercises/update",
    params
  );
};

/**分页查询习题 */
export const queryByPage = (params: QueryParams) => {
  return request.get<QueryParams, ResponseBody<PageResult<QueryResult>>>(
    "/answer/exercises/page",
    { params }
  );
};

/**删除习题 */
export const del = (params: DeleteParams) => {
  return request.delete<DeleteParams, ResponseBody>(
    "/answer/exercises/delete",
    {
      params,
    }
  );
};
